home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2008 January / Cybermycha 1_2008.iso / Data.cab / _56BED3C178C146CB8DD8E70A02EB5A36 < prev    next >
Encoding:
Text File  |  2004-05-27  |  2.8 KB  |  85 lines

  1. regc( 0, "TFACTOR" )
  2. regc4f( 3, %dirtcolor_r, %dirtcolor_g, %dirtcolor_b, %sunvisibility )
  3. regc4f( 4, %dirtsnow, %dirtgravel, %dirtmud, 0.0 )
  4. regc4f( 5, %daycolor_r, %daycolor_g, %daycolor_b, %daycolor_a )
  5. regc4f( 7, %ambient_r, %ambient_g, %ambient_b, %ambient_a )
  6.  
  7. hlsl("
  8. #include <../common_hlsl.h>
  9. #include <cardef.h>
  10.  
  11. sampler2D    sColor: register(s0);     
  12. sampler2D    sDirt: register(s1);    
  13. sampler2D    sClouds: register(s2);
  14. sampler2D    sLightmap: register(s3);
  15. samplerCUBE    sCubemap: register(s4);
  16. sampler2D    sDirtNormalmap: register(s5);
  17. sampler2D    sBroken: register(s6);
  18.  
  19. const HALF4 TFactor : register(c0); // TFactor.b = refl strength TFactor.a - DirtLevel
  20. const HALF4 DirtColor_Sun : register(c3);
  21. const HALF3 DirtType : register(c4);
  22. const HALF3 DayColor : register(c5);
  23. const HALF4 Ambient : register(c7);
  24.  
  25. static const HALF3 Tiling = {SNOWTILING/3, GRAVELTILING/3, MUDTILING/3};
  26. static const HALF3 FlatNormal = {0.0f, 0.0f, 1.0f};
  27.  
  28. struct PS_INPUT
  29. {
  30.     HALF        SpotDiffuse: COLOR0;
  31.     HALF2       uvColor : TEXCOORD0;
  32.     float3      L : TEXCOORD1;
  33.     float3      R_ts : TEXCOORD2;
  34.     float3         R_ws: TEXCOORD3;
  35.     float4        FresnelFog : TEXCOORD4;
  36.     HALF2       uvClouds: TEXCOORD5;
  37.     HALF2       uvLightmap: TEXCOORD6;
  38. };    
  39.     
  40. HALF4 main( PS_INPUT i ): COLOR {
  41.  
  42.     HALF3 DirtColor = DirtColor_Sun.rgb;
  43.     HALF SunVisibility = DirtColor_Sun.a;
  44.     HALF ReflStrength = TFactor.b;
  45.     HALF DirtLevel = TFactor.a;
  46.     HALF DirtMask = dot(tex2D( sDirt, i.uvColor ), DirtType)*DirtLevel;
  47.     HALF3 DirtNormalmapTiling = dot(DirtType, Tiling);
  48.     HALF3 Normalmap = tex2D( sDirtNormalmap, i.uvColor*DirtNormalmapTiling )*2 - 1;
  49.     Normalmap = lerp( FlatNormal, Normalmap, DirtMask);
  50.     HALF Diffuse = diffuse( Normalmap, i.L);
  51.     HALF Specular = phong(i.R_ts, i.L, SPECULARPOW)*SunVisibility;
  52.     HALF3 Cubemap    = texCUBE( sCubemap, i.R_ws);
  53.     
  54.     HALF Clouds = 1-(tex2D(sClouds, i.uvClouds)).a;
  55.     HALF Lightmap = saturate((tex2D(sLightmap, i.uvLightmap)).a);
  56.     HALF Shadows = saturate(Clouds*Lightmap*SHADOWSMUL+SOFTSHADOWS);
  57.  
  58.     Diffuse = saturate(Ambient.r*Shadows*Diffuse + Ambient.a);
  59.  
  60.     HALF4 Color = tex2D( sColor, i.uvColor );
  61.  
  62.     ReflStrength = i.FresnelFog.x; //+ReflStrength
  63.     HALF CubemapMask = (1-DirtMask)*ReflStrength;
  64.     HALF SpecularMask = (1-DirtMask)*Shadows; 
  65.     HALF Broken = tex2D(sBroken, i.uvColor).b;
  66.     
  67.     Color.rgb = lerp( Color, DirtColor, DirtMask);
  68.     Color.rgb = saturate(Color.rgb+Broken);
  69. #if VS_SPOTLIGHTS
  70.     HALF3 Spot = Color.rgb*i.SpotDiffuse;    
  71. #endif    
  72.     Color.rgb = saturate(Color*Diffuse+Specular*SpecularMask+Cubemap*CubemapMask)*DayColor;
  73.     Color.a = lerp(Color.a, 1, DirtMask);
  74.     Color.a += dot(Color.rgb, HALF3( 0.13f, 0.23f, 0.33f));
  75.     // korekcja mgly
  76.     Color.a = saturate(Color.a*(1-i.FresnelFog.y)+Color.a);
  77.     // spot lighting
  78. #if VS_SPOTLIGHTS
  79.     Color.rgb = saturate(Color+Spot);    
  80. #endif    
  81.     return Color;
  82. }
  83. ")
  84.  
  85.